package pers.lan.hash;

/**
 * @author <p><a href="mailto:1728209643@qq.com">XiaoSan</a>
 * @date 2019/11/23 3:38 PM
 */
public class LC_525 {

    public static void main(String[] args) {
        System.out.println(findMaxLength(new int[]{0, 1}));
    }

    public static int findMaxLength(int[] nums) {
        int last = 0;
        int c0 = 0;
        int c1 = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 0) {
                c0++;
            } else {
                c1++;
            }
            if (c0 == c1) {
                last = i;
            }
        }
        return last ;
    }
}
